﻿using System.Web;
using Wikey.Entity;

namespace Wikey.Domain.Web {
    public class Authorization {

        public static bool IsGuest
        {
            get
            {
                return CurrentUser == null;
            }
        }
        
        public static User CurrentUser
        {
            get
            {
                return HttpContext.Current.Session["user"] as User;
            }
            set
            {
                HttpContext.Current.Session["user"] = value;
            }

        }

        public static string CurrentUserName
        {
            get
            {
                User current = CurrentUser;
                if (current == null)
                {
                    return "Guest";
                }
                return current.Name;
            }
        }
    }
}
